﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Formatters.Xml;
using Microsoft.Extensions.Logging;
using DeMeng.Models;
using DeMeng.Models.Swagger;
using DeMeng.Services.Domain;
using DeMeng.Models.Models.Poster;

namespace DeMeng.Api.Controllers
{

    public class HomeController : Controller
    {
        private readonly ILogger<HomeController> _logger;
        private readonly IPosterServices _posterServices;

        public HomeController(ILogger<HomeController> logger, IPosterServices posterServices)
        {
            _logger = logger;
            _posterServices = posterServices;
        }

        public IActionResult Index()
        {
            PosterListViewModel viewModel = new PosterListViewModel();
            viewModel.TopList = _posterServices.Query(s => s.RecommendType == 1 && s.IsShow && s.ShowStartTime <= DateTime.Now && s.ShowEndTime >= DateTime.Now, " Sort asc  ").Result;

            viewModel.BoutiqueList = _posterServices.Query(s => s.RecommendType == 2 && s.IsShow && s.ShowStartTime <= DateTime.Now && s.ShowEndTime >= DateTime.Now, " Sort asc  ").Result;
            viewModel.RecommendationList = _posterServices.Query(s => s.RecommendType == 3 && s.IsShow && s.ShowStartTime <= DateTime.Now && s.ShowEndTime >= DateTime.Now, " Sort asc  ").Result;

            return View(viewModel);
        }
        public IActionResult PlayerNotice()
        {
            return View();
        }

    }
}
